package com.mproject.activity;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

import com.mproject.network.IVLE_API_Helper;


public class Dashboard_TabView extends TabActivity {

	private TextView welcome_name;
	public static TabHost tabHost;
	public static SharedPreferences mypref;
	Class classes[]={Dashboard_TabGroup1.class,Dashboard_TabGroup2.class};

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab_view_layout);  

		welcome_name = (TextView) findViewById(R.id.welcome_name_dashboard);
		mypref=getSharedPreferences("My_Prefs",Activity.MODE_WORLD_WRITEABLE);


		welcome_name.setText("Hi "+mypref.getString("user_name", ""));

		setTabs();
	}

	private void setTabs() 
	{
		tabHost = getTabHost();

		addTab("Projetcs", R.color.tab_project,0);
		addTab("Upcoming", R.color.tab_upcoming,1);
	}

	private void addTab(String labelId, int drawableId, int num) {

		Intent intent = new Intent(this, classes[num]);
		//intent.putExtra("user",user);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);		

		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);

		TextView title = (TextView) tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
		icon.setImageResource(drawableId);

		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		//spec.setContent(ids[0]);
		tabHost.addTab(spec);

	}
}